import React, { Component } from 'react';

import {
  BrowserRouter as Router,
  Route,
  Switch,
  Redirect,
} from 'react-router-dom';
import Login from './pages/Login';
import Layout from './pages/Layout';
import { hasToken } from 'utils/strorage';

export default class App extends Component {
  render() {
    return (
      <Router>
        <Switch>
          <Route path="/login" component={Login}></Route>
          <Route
            path="/"
            render={(_props) => {
              console.log(' _props ----->  ', _props);
              if (hasToken()) {
                return <Layout {..._props} />;
              }
              return <Redirect to="/login" />;
            }}
          ></Route>
        </Switch>
      </Router>
    );
  }
}
